/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.feiyue.basic.reader.util;

import info.monitorenter.cpdetector.io.ASCIIDetector;
import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
import info.monitorenter.cpdetector.io.JChardetFacade;
import info.monitorenter.cpdetector.io.ParsingDetector;
import info.monitorenter.cpdetector.io.UnicodeDetector;
import java.io.File;
import java.net.URI;
import java.nio.charset.Charset;

public class ChapterUtil {
	public static String getFileCharacterEnding(File paramFile) {
		String str = "UTF-8";
		CodepageDetectorProxy localCodepageDetectorProxy = CodepageDetectorProxy
				.getInstance();
		localCodepageDetectorProxy.add(JChardetFacade.getInstance());
		Charset localCharset1;
		try {
			Charset localCharset2 = localCodepageDetectorProxy
					.detectCodepage(paramFile.toURL());
			localCharset1 = localCharset2;
			if (localCharset1 != null)
				str = localCharset1.name();
		} catch (Exception localException) {
			localException.printStackTrace();
			localCharset1 = null;
		}
		
		return str;
	}

	public static String getFileEncode(String paramString) {
		CodepageDetectorProxy localCodepageDetectorProxy = CodepageDetectorProxy
				.getInstance();
		localCodepageDetectorProxy.add(new ParsingDetector(false));
		localCodepageDetectorProxy.add(JChardetFacade.getInstance());
		localCodepageDetectorProxy.add(ASCIIDetector.getInstance());
		localCodepageDetectorProxy.add(UnicodeDetector.getInstance());
		File localFile = new File(paramString);
		Charset localCharset1;
		try {
			Charset localCharset2 = localCodepageDetectorProxy
					.detectCodepage(localFile.toURI().toURL());
			localCharset1 = localCharset2;
			if (localCharset1 != null) {
				return localCharset1.name();
			}
		} catch (Exception localException) {
			localException.printStackTrace();
			localCharset1 = null;
		}
		
		return null;
	}
}